package UseString.demo02;

import java.util.Scanner;

public class NumberTransform {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入数字");
        int number = sc.nextInt();
        // 转换数字拿到一个的数字
        String result = "";
        while (true){
            int n = number % 10;
            String s = transCapital(n);
            result = s + result;
            number = number / 10;
            if(number==0){
                break;
            }
        }
        // 拼接零前缀
        int count = 7 -result.length();
        for (int i = 0; i < count; i++) {
            result = "零" + result;
        }
        // 拼接单位
        String[] unit = {"佰","拾","万","仟","佰","拾","元"};
        String finalResult = "";
        for (int i = 0; i < result.length(); i++) {
            char c = result.charAt(i);
            finalResult = finalResult + c + unit[i];
        }
        System.out.println(finalResult);
    }
    public static String transCapital(int i){
        String[] arr = {"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
        return arr[i];
    }
}
